<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list</title>
<#include "/admin/include/head.htm">
<script type="text/javascript">
    var grid;
    $(function () {
        grid = $("#maingrid").ligerGrid({
            columns: [
                {hide: true, name: 'path'},
			{display: 'ID', name: 'id', align: 'left', width:50},
			{display: '品牌名称', name: 'name', align: 'left', width: 300, render:function(row){
				return "<a target='_blank' style='color:blue' href='"+row["path"]+"'>"+row["name"]+"</a>";
			}},
			{display: '网址', name: 'url', align: 'left', minWidth: 360 },
            {display: 'LOGO', name: 'logo', align: 'center', width: 150,
            	render: function (row){				
					if (row["logo"]) {
						var html = '<a href="' + base + row["logo"] + '" class="imagePreview" target="_blank">查看</a>';
						return html;
					}
            	} 
            },
			{display: '是否推荐', name: 'isRecommend', align: 'center', dict:'common',width:60},
			{display: '排序', name: 'priority', align: 'center', width: 150 }
			],  pageSize:20, url: '${base}/admin/b2c/brand/queryData.jhtml?sortname=priority&sortorder=asc',
			toolbar: {}, width: '100%', height:'100%', enabledSort: true
        });
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		
		//绑定搜索按钮
		LG.search(grid);
    });
	
	function add(){
		top.f_addTab(null, '新增品牌', '${base}/admin/b2c/brand/add.jhtml');
	}
	
	function edit() {
		var selecteds = grid.getSelecteds();
		if (selecteds.length != 1) { 
			LG.tip('请选择一行记录!'); 
			return; 
		}
		
		var id = selecteds[0].id;
		if(top.f_isTabItemExist("brand" + id)){
			top.f_switchTab("brand" + id);
		}else{
			top.f_addTab("brand" + id, '修改品牌[' + selecteds[0].name + ']', '${base}/admin/b2c/brand/edit.jhtml?id=' + id);
		}
	}
	
	function f_delete() {
		var selecteds = grid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定删除吗？', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/b2c/brand/delete.jhtml',
			            loading: '正在删除中...',
			            data: { ids: LG.getIds(selecteds) },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请选择行!');
	    }
	}
	
	function f_import(){
		$.ligerDialog.open({
	        target: $("#importDiv"),
	        title: '导入',
	        width: 380,
	        height: 120,
	        isResize: true,
	        modal: true,
	        buttons: [{ 
	        	text: '确定', 
	        	onclick: function (i, d) {
		        	$("#importForm").ajaxSubmit({
		        		success:function(data){
	        				$.ligerDialog.hide();
		        			LG.showSuccess(data);
		        			$("#importForm")[0].reset();
		        			grid.loadData();
		        		}
		        	});
		        }
	        }, { 
	        	text: '关闭', 
	        	onclick: function (i, d) {
	        		$.ligerDialog.hide();
	            }
	        }]
		});
	}
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="functions">
		<div class="clearfix">
			<div style="float:left;">
				<span>
					品牌名称：<input type="text" class="formText" name="search_LIKE_name"/>
				</span>
				<input type="button" id="search" class="button" value="搜索"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">解除搜索,显示全部数据</a>
			</div>
		</div>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
	<div id="importDiv" style="display: none;">
		<form action="${base}/admin/b2c/brand/import.jhtml" method="post" id="importForm">
			<table style="margin-top: 10px;">
				<tr>
					<td>导入类型</td>
					<td>
						<select name="type">
							<option value="brand">导入品牌</option>
							<option value="brandRelation">导入品牌关联</option>
						</select>
					</td>
				</tr>
				<tr>
					<td colspan="2"><input type="file" name="importFile" /></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>